import PopupManager from "../../eazax-ccc/core/PopupManager";
import ToastManager from "../../eazax-ccc/core/ToastManager";
import MainContent from "./MainContent";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Bottom extends cc.Component {

    @property(cc.Button)
    private btnMain: cc.Button = null;
    @property(cc.Button)
    private btnPanel: cc.Button = null;
    @property(cc.Button)
    private btnToast: cc.Button = null;

    protected onLoad() {
        this.registerEvent();
    }

    protected onDestroy() {
        this.unregisterEvent();
    }

    private registerEvent() {
        this.btnMain.node.on(cc.Node.EventType.TOUCH_END, this.onBtnMainClick, this);
        this.btnPanel.node.on(cc.Node.EventType.TOUCH_END, this.onBtnPanelClick, this);
        this.btnToast.node.on(cc.Node.EventType.TOUCH_END, this.onBtnToastClick, this);
    }

    private unregisterEvent() {
        this.btnMain.node.off(cc.Node.EventType.TOUCH_END, this.onBtnMainClick, this);
        this.btnPanel.node.off(cc.Node.EventType.TOUCH_END, this.onBtnPanelClick, this);
        this.btnToast.node.off(cc.Node.EventType.TOUCH_END, this.onBtnToastClick, this);
    }

    private onBtnMainClick(event: cc.Event.EventTouch) {
        MainContent.goCase(event.target.name);
    }
    private onBtnPanelClick(event: cc.Event.EventTouch) {
        PopupManager.show('prefabs/cases/dialog', 123,)

    }
    private onBtnToastClick(event: cc.Event.EventTouch) {
        ToastManager.show('哈哈哈哈')
    }
}
